<?php

namespace App\Listeners;

use App\Events\MachineGoodsEvent;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Support\Facades\Redis;

class MachineGoodsListeners
{
    /**
     * Create the event listener.
     *
     * @return void
     */
    public function __construct()
    {
        //
    }

    /**
     * Handle the event.
     *
     * @param  MachineState  $event
     * @return void
     */
    public function handle(MachineGoodsEvent $event)
    {   
        $freights = $event->freight;
        if($freights->isNotEmpty()){
            foreach ($freights as $key => $value) {
                $value->goods_id = 0;
                $value->save();
            }
        }
    }
}
